ifneq ($(ComSpec),)
RM=del
else
RM=rm
endif

CASTLING_DIR=../source

.PHONY: clean
.DELETE_ON_ERROR: generated.ml

Generated.html Castling.html: generated.mli syntax.ml remove_private.ml generated.ml
	ocamlc -c generated.mli
	ocamlc -i $(CASTLING_DIR)/castling.ml | ocaml remove_private.ml > castling.mli
	ocamldoc -html -I . -m A -hide Castling.ParserGenerator.Private castling.mli $(CASTLING_DIR)/castling.ml generated.mli generated.ml
	$(RM) *.cm? castling.mli generated.ml

generated.ml: $(CASTLING_DIR)/lalr1.ml $(CASTLING_DIR)/castling.ml token.ml syntax.ml
	ocamlc -c -o lalr1.cmo $(CASTLING_DIR)/lalr1.ml
	ocamlc -c -o castling.cmo $(CASTLING_DIR)/castling.ml
	ocamlc -c token.ml
	ocaml lalr1.cmo castling.cmo token.cmo syntax.ml > generated.ml

clean:
	$(RM) *.html *.css
